<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<title>约泡浪呀榜</title>
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="format-detection" content="email=no" />
	<meta name="apple-mobile-web-app-title" content="一道走">
	<meta name="description" content="" />
	<meta name="keywords" content="" />
	<link rel="stylesheet" href="src/css/s.min.css">
	<script>
		(function(){
			var phoneWidth =  parseInt(window.screen.width);
			var phoneScale = phoneWidth/640;
			var isAndroid = RegExp("Android").test(navigator.userAgent);
			if (isAndroid) {
				document.write('<meta name="viewport" content="width=640, minimum-scale = '+phoneScale+', maximum-scale = '+phoneScale+', target-densitydpi=device-dpi">');
			} else {
				document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
			}
		}());
	</script>
</head>

<style>
	.ranks-wrapper .pro-0 {
		display: block;
		position: absolute;
		width: 513px;
		height: 503px;
		left: 50%;
		margin-left: -240px;
		top: 604px;
	}
</style>
<body class="app" style="width: 100%;background: #FFFFFF;">

<div class="container" style="width: 640px;margin: 0 auto;height: auto;">
	<div class="ranks-wrapper">
		<img id="J_img" src="" alt="" width="82" height="82" />
		<p class="nick"></p>
		<a id="gresult" class="pro-0" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1790"></a>
		<div id="J_pro_txt" class="pro-txt"></div>
		<a class="pro-1" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1646"></a>
		<a class="pro-2" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1925"></a>
		<a class="pro-3" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1774"></a>
		<a class="pro-4" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1790"></a>
		<a class="pro-5" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1647"></a>
		<a class="pro-6" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1643"></a>
		<a class="pro-7" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1770"></a>
		<a class="pro-8" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1783"></a>
		<a class="pro-9" href="http://m.yidaozou.com/html/yidaozou/yapp/calendar-price.html?group_id=1744"></a>
		<a href="http://m.yidaozou.com/html/langyabang/app.html" class="back-btn"></a>
	</div>
</div>

<script src="src/js/zepto.min.js"></script>
<script>

	Zepto(function($){

		var placeNameMap = {
			'1': '天目湖御水温泉',
			'2': '清远森波拉温泉',
			'3': '北京九华山庄温泉',
			'4': '新丰云天海温泉',
			'5': '天目湖涵田半山温泉',
			'6': '苏州天颐温泉',
			'7': '北京热带雨林风情园温泉',
			'8': '天津天鹅湖温泉',
			'9': '广州香江健康山谷'
		};

		var getParam = function(name){
			var search = document.location.search;
			var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
			var matcher = pattern.exec(search);
			var items = null;
			if(null != matcher){
				try{
					items = decodeURIComponent(decodeURIComponent(matcher[1]));
				}catch(e){
					try{
						items = decodeURIComponent(matcher[1]);
					}catch(e){
						items = matcher[1];
					}
				}
			}
			return items;
		};


		var isWeixin = function() {
			var ua = navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == 'micromessenger') {
				return true;
			} else {
				return false;
			}
		};

		var rankNum = getParam('rank') || 1;
		var nickname = getParam('nickname');
		var openid = getParam('openid');
		var img = getParam('img');

		$('#J_pro_txt').addClass('pro-txt-' + rankNum);

		if (isWeixin()) {
			window.location =
					'http://api.one-dao.com/api/wechat/getAuthorizeUrl?successUrl=' + encodeURIComponent(window.location.href)
			var script = document.createElement("script");
			script.src = "http://res.wx.qq.com/open/js/jweixin-1.0.0.js";
			script.onload = function () {
				var wxScript = document.createElement("script");
				wxScript.src = "http://m.yidaozou.com/html/langyabang/src/js/weixin.js";
				wxScript.onload = function () {
					if (openid) {
						var pr = JSON.stringify({
							common: {},
							data: {
								open_id:  openid // 自行获取
							}
						});
						$.ajax({
							url: "http://api.one-dao.com/api/wechat/getUserInfoByOpenId?parameters=" + encodeURIComponent(pr),
							async: false,
							type: "POST",
							dataType: "jsonp",
							jsonp: "callback",
							jsonpCallback: "jsonpCallback",
							success: function (result) {
								var nickName = '';
								var imgUrl = '';
								if (result.code == 1) {
									nickName = result.data.nickname || nickname;
									imgUrl = result.data.img || img;
									$('#J_img').attr('src', imgUrl)
									$('.nick').text(nickName)
									new Weixin().init({
										desc: nickName + "的最佳约泡地是" + placeNameMap[rankNum] + "，位列浪呀榜第" + rankNum
									});
								}
							},
							fail: function (result) {
								alert(JSON.stringify(result));
							}
						});
					}
				};
				document.head.appendChild(wxScript)
			};
			document.head.appendChild(script)
		}
	})
</script>

</body>

</html>
